import path from 'path';
import { Context, Plugin } from '../core';
import { copy } from '../utils';

export class CopyPlugin implements Plugin {
  name = 'copy';

  async generateEnd(context: Context) {
    await Promise.all(context.config.copy.map(dir => {
      const src = path.resolve(context.config.root, dir);
      const dest = path.resolve(context.config.output.path);

      return copy(src, dest);
    }));
  }
}
